package com.yzpass.api.user.controller;

import com.yzpass.api.common.Constant;
import com.yzpass.api.common.FilterDTO;
import com.yzpass.api.common.Result;
import com.yzpass.api.security.annotation.*;
import com.yzpass.api.user.dto.UserDTO;
import com.yzpass.api.user.dto.UserPassResetDTO;
import com.yzpass.api.user.entity.User;
import com.yzpass.api.user.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping(value = Constant.API + "user")
public class UserController {
    public final String resId = "user";
    @Resource
    UserService userService;

    @RequireFullControl(resId)
    @DeleteMapping("{id}")
    public Result delete(@PathVariable("id") String id) {
        return userService.delete(id);
    }

    @RequireEdit(resId)
    @PostMapping("save")
    public Result<UserDTO> save(@RequestBody UserDTO input) {
        return userService.save(input);
    }

    @RequireRead(resId)
    @GetMapping("view/{id}")
    public Result<UserDTO> view(@PathVariable("id") String id) {
        return userService.view(id);
    }

    @RequireRead(resId)
    @PostMapping("list")
    public Result<List<UserDTO>> list(@RequestBody FilterDTO input) {
        return userService.list(input);
    }

    @RequirePermission(resId)
    @PostMapping("passReset/{id}")
    public Result<UserPassResetDTO> passReset(@PathVariable("id") String id) {
        return userService.passReset(id);
    }
}

